let v = new Vue({
    el:"#main-container",
    data:{
      pageInfo:{
          pageSize:5
      },
      type:'',
      statute:{
          pubDate:"2020-6-21"
      },
      myConfig:{
          UEDITOR_HOME_URL:'static/ueditor/',
          serverUrl:'ueditor',
          maximumWords:500000
      },
      flag:true
    },
    methods:{
        selectByPage:function(page,pageSize){
            axios({
                url:`manager/statute/select/${page}/${pageSize}`,
                method:'get',
                params:{type:this.type}
            }).then(resp => {
                this.pageInfo = resp.data.obj;
            }).catch(error => {
                console.log(error);
            })
        },
        select:function (page,pageSize) {
            this.type = '';
            this.selectByPage(page,pageSize);
        },
        add:function () {
            axios({
                url:'manager/statute/add',
                method:'post',
                data:this.statute
            }).then(resp => {
                this.flag = true;
                this.statute = {};
            }).catch(error => {
                console.log(error);
            })
        },
        changeFlag:function () {
            this.flag = !this.flag;
        },
        ifDelete:function(id){
            axios({
                url:`manager/statute/delete/${id}`,
                method:'delete'
            }).then(resp => {
                this.select(this.pageInfo.pageNum,this.pageInfo.pageSize);
            }).catch(error => {
                console.log(error);
            })
        },
        toUpdate:function (s) {
            layer.obj = s;
            layer.open({
                type: 2,
                title: '更新',
                area: ['60%', '60%'],
                content: 'manager/statute/toUpdate',
                end:() => {
                    if(!layer.success){
                        this.select(1,this.pageInfo.pageSize);
                    }
                }
            })
        }
    },
    components:{
        VueUeditorWrap
    },
    created:function () {
        this.select(1,this.pageInfo.pageSize);
    }
})